Testing the different components of the enveloppe

  |   Source

Motion Clouds: testing components of the envelope

In []:
import numpy as np
np.set_printoptions(precision=3, suppress=True)
import pylab
import matplotlib.pyplot as plt
%matplotlib inline
  Hide output
In [46]:
import MotionClouds as mc
fx, fy, ft = mc.get_grids(mc.N_X, mc.N_Y, mc.N_frame)
  Hide output
In [47]:
def show_mc(name):
    import os
    from IPython.display import display, Image
    if os.path.isfile(name + mc.ext):
        display(Image(filename=name + mc.ext))
    if os.path.isfile(name + '_cube' + mc.ext):
        display(Image(filename=name + '_cube' + mc.ext))
    from IPython.display import HTML
    from base64 import b64encode
    video = open(name + mc.vext, "rb").read()
    video_encoded = b64encode(video)
    video_tag = '<video controls  autoplay="autoplay" loop="loop" width=50% src="data:video/x-m4v;base64,{0}">'.format(video_encoded)
    display(HTML(data=video_tag))
  Hide output

Testing the color

In [48]:
name = 'color'
z = mc.envelope_color(fx, fy, ft)
if mc.anim_exist(mc.figpath + name): mc.figures(z, mc.figpath + name)
show_mc(mc.figpath + name)
  Hide output
In [48]:
 
  Hide output
In [48]:
 
  Hide output
In [48]:
 
  Hide output
In [49]:
# explore parameters
for alpha in [0.0, 0.5, 1.0, 1.5, 2.0]:
    # resp. white(0), pink(1), red(2) or brownian noise (see http://en.wikipedia.org/wiki/1/f_noise
    name_ = mc.figpath + name + '-alpha-' + str(alpha).replace('.', '_')
    if mc.anim_exist(name_):
        z = mc.envelope_color(fx, fy, ft, alpha)
        mc.figures(z, name_)
    show_mc(name_)
  Hide output
In [50]:
for ft_0 in [0.125, 0.25, 0.5, 1., 2., 4.]:# time space scaling
    name_ = mc.figpath + name + '-ft_0-' + str(ft_0).replace('.', '_')
    if mc.anim_exist(name_):
        z = mc.envelope_color(fx, fy, ft, ft_0=ft_0)
        mc.figures(z, name_)
    show_mc(name_)
  Hide output
In [51]:
for contrast in [0.1, 0.25, 0.5, 0.75, 1.0, 2.0]:
    name_ = mc.figpath + name + '-contrast-' + str(contrast).replace('.', '_')
    if mc.anim_exist(name_):
        im = mc.rectif(mc.random_cloud(mc.envelope_color(fx, fy, ft)), contrast)
        mc.anim_save(im, name_, display=False)
    show_mc(name_)
  Hide output
In [52]:
for contrast in [0.1, 0.25, 0.5, 0.75, 1.0, 2.0]:
    name_ = mc.figpath + name + '-energy_contrast-' + str(contrast).replace('.', '_')
    if mc.anim_exist(name_):
        im = mc.rectif(mc.random_cloud(mc.envelope_color(fx, fy, ft)), contrast, method='energy')
        mc.anim_save(im, name_, display=False)
    show_mc(name_)
  Hide output
In [53]:
for seed in [123456 + step for step in range(7)]:
    name_ = mc.figpath + name + '-seed-' + str(seed)
    if mc.anim_exist(name_):
        mc.anim_save(mc.rectif(mc.random_cloud(mc.envelope_color(fx, fy, ft), seed=seed)), name_, display=False)
    show_mc(name_)
  Hide output
In [54]:
for size in range(5, 7):
    N_X, N_Y, N_frame = 2**size, 2**size, 2**size
    fx, fy, ft = mc.get_grids(N_X, N_Y, N_frame)
    ft_0 = N_X/float(N_frame)
    name_ = mc.figpath + name + '-size-' + str(size).replace('.', '_')
    if mc.anim_exist(name_):
        z = mc.envelope_color(fx, fy, ft, ft_0=ft_0)
        mc.figures(z, name_)
    show_mc(name_)
  Hide output
In [55]:
for size in range(5, 7):
    N_frame = 2**size
    fx, fy, ft = mc.get_grids(mc.N_X, mc.N_Y, N_frame)
    ft_0 = N_X/float(N_frame)
    name_ = mc.figpath + name + '-size_T-' + str(size).replace('.', '_')
    if mc.anim_exist(name_):
        z = mc.envelope_color(fx, fy, ft, ft_0=ft_0)
        mc.figures(z, name_, do_figs=False)
    show_mc(name_)
  Hide output
In [56]:
#name = 'colorfull'
#N = 256 #512
#fx, fy, ft = mc.get_grids(N, N, N)
#for seed in [123456 + step for step in range(1)]:
#    if mc.anim_exist(mc.figpath + name):
#        mc.anim_save(mc.rectif(mc.random_cloud(mc.envelope_color(fx, fy, ft), seed=seed)), mc.figpath + name, display=False)
#        mc.anim_save(mc.rectif(mc.random_cloud(mc.envelope_color(fx, fy, ft), seed=seed)), mc.figpath + name, display=False, vext='.mat')
  Hide output

Testing the speed

In []:
 
  Hide output
Comments powered by Disqus
    Share